﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace Xiaov.SmartWeb.Model.Statistical.Select
{
    public class DwbmSelect:ISelect
    {
        public string DefaultValue
        {
            get;
            set;
        }

        public List<System.Web.UI.WebControls.ListItem> ListItems
        {
            get;
            set;
        }

        public void DataBind(string dw, string tn, string nf, string yf)
        {
            ListItems = new List<System.Web.UI.WebControls.ListItem>();
            string sql = "select y.dwmc,t.dwbm from bbdytbdw t,dwbmb y where t.dwbm=y.dwbm and t.bbbm='" + tn.ToUpper() + "' and t.dwbm like '" + dw + "%' order by xssx";
            System.Data.OracleClient.OracleDataReader reader = Maticsoft.DBUtility.DbHelperOra.ExecuteReader(sql);
            while (reader.Read())
            {
                ListItems.Add(new ListItem(reader[0].ToString(), reader[1].ToString()));
            }
            reader.Close();
            bool f = ListItems.Where(s => s.Value == dw).Count() > 0;
            if (!f)
                DefaultValue = ListItems[0].Value;
            else
                DefaultValue = dw;
            
        }
    }
}
